/**
 * @param {number[]} nums
 * @param {number} val
 * @return {number}
 */
var removeElement = function(nums, val) {
    for (let index = 0; index < nums.length; index++) {
        const element = nums[index];
        if(element === val) {
            console.log(index,nums);
            
            nums.splice(index, 1);
            index--
        }
    }
    return  nums.length
};
removeElement([0,1,2,2,3,0,4,2],2)
// console.log(removeElement([0,1,2,2,3,0,4,2],2));